package com.mgblog.service.imp;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.mgblog.dao.inter.ArticleDaoInter;
import com.mgblog.dao.inter.ArticleSortDaoInter;
import com.mgblog.service.inter.ArticleServiceInter;
import com.mgblog.utils.Pager;
import com.mgblog.vo.Article;
import com.mgblog.vo.ArticleSort;
/**
 * 
 * @author meigang 2014-11-26 16:32
 * 文章的业务实现类
 */
@Transactional
@Service("articleService")
public class ArticleServiceImp implements ArticleServiceInter{
	@Resource
	private ArticleDaoInter articleDao;
	@Resource
	private ArticleSortDaoInter articleSortDao;

	@Override
	public void addArticle(Article a) {
		// TODO Auto-generated method stub
		//先将该分类的articleNum加1
		articleSortDao.addArticleNum(a.getArticleSort());
		//添加文章到数据库
		articleDao.addArticle(a);
	}

	@Override
	public int count() {
		// TODO Auto-generated method stub
		
		return articleDao.count();
	}

	@Override
	public Pager findArticlePage(Pager page, String string) {
		// TODO Auto-generated method stub
		return articleDao.findArticlePage(page,string);
	}

	@Override
	public Article findArticleById(int id) {
		// TODO Auto-generated method stub
		return articleDao.findArticleById(id);
	}

	@Override
	public Pager findArticlePageByArticle(Pager page, String string,
			ArticleSort as) {
		// TODO Auto-generated method stub
		return articleDao.findArticlePageByArticle(page,string,as);
	}

	
	

}
